//
//  WaitingVC.m
//  Mahjong
//
//  Created by 饶首建 on 17/6/27.
//  Copyright © 2017年 com.ikamobile.com. All rights reserved.
//


#import "WaitingVC.h"
#import "MahjongTypeCollectionViewCell.h"

@interface WaitingVC ()<UICollectionViewDelegate,UICollectionViewDataSource>

@property (weak, nonatomic) IBOutlet UICollectionView *collectionView;
@property (weak, nonatomic) IBOutlet UILabel *tipLabel;
@property (nonatomic,strong) NSMutableArray *playerArr;

@end
static NSString *kMahjongTypeCollectionViewCell = @"kMahjongTypeCollectionViewCell";
@implementation WaitingVC

- (void)viewDidLoad {
    [super viewDidLoad];
    _playerArr = [NSMutableArray new];
    _tipLabel.text = @"请等待牌局设置完成";//请等待其他玩家加入
    [_playerArr addObjectsFromArray:@[@"玩家A",@"玩家B",@"玩家C",@"玩家D"]];
    [_collectionView registerClass:[MahjongTypeCollectionViewCell class] forCellWithReuseIdentifier:kMahjongTypeCollectionViewCell];
}
#pragma mark - UICollectionViewDelegate
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{
    return 1;
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
    return _playerArr.count;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
    MahjongTypeCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:kMahjongTypeCollectionViewCell forIndexPath:indexPath];
    
    UIImageView *headIgv = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 150, 150)];
    [cell addSubview:headIgv];
    headIgv.image = UIImageWithName(@"userinfo_big");
    UILabel *nameLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 150, 150, 50)];
    nameLabel.textAlignment = NSTextAlignmentCenter;
    nameLabel.font = DefaultSystemFont(18);
    nameLabel.textColor = [UIColor lightGrayColor];
    nameLabel.adjustsFontSizeToFitWidth = YES;
    [cell addSubview:nameLabel];
    nameLabel.text = _playerArr[indexPath.row];
    
    return cell;
}

- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
    [collectionView deselectItemAtIndexPath:indexPath animated:YES];
    
}

- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath{
    return CGSizeMake(150,200);
}
/**
 *  section的内边距
 */
- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section{
    return UIEdgeInsetsMake(0, 0, 0, 0);
}
/**
 *  item之间的行距
 */
- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section{
    return 10;
}
/*
 *  item之间的左右间距
 */
- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section{
    return 5;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
